package com.ttl.bc.vat.apwtaxlist.db;

import java.util.Date;

import org.apache.struts.action.ActionForm;

import com.ttl.bc.ap.invoice.action.BCAPInvoice2Form;
import com.ttl.bc.vat.apwtaxlist.bean.BCAPWTaxListBean;
import com.ttl.common.util.CommonUtils;

public class BCAPWTaxListBO {

	public static Object getObject(ActionForm form) {
		
		BCAPInvoice2Form invForm =(BCAPInvoice2Form)form; 
		
		BCAPWTaxListBean wTax = new BCAPWTaxListBean();
		wTax.setDocNo(invForm.getDocNo());
		wTax.setDocDate( CommonUtils.convertStringToDate(invForm.getDocDate()));
		wTax.setApCode(invForm.getApCode());
		wTax.setBaseOfTax(Double.valueOf(invForm.getSumOfItemAmount()));
		
		wTax.setwTaxRate(3.0);
		wTax.setwTaxAmount(wTax.getBaseOfTax()*wTax.getwTaxRate()/100);
		wTax.setLineNumber(0);
		wTax.setShortDesc("ค่าบริการ (data from ittl)");
		
		String month = CommonUtils.getCurrentDateFormat("MM");
		String year = "";
		if (new Integer(CommonUtils.getCurrentDateFormat("yyyy")) < 2500) {
			year = new String(""+(new Integer(CommonUtils.getCurrentDateFormat("yyyy"))+543)).substring(2, 2);
		}else {
			year = new String(""+(new Integer(CommonUtils.getCurrentDateFormat("yyyy")))).substring(2, 2);
		}
		
		wTax.setTaxGroup(year+ " FC "+ month );
		wTax.setSaveFrom(1);
		wTax.setPayDate( CommonUtils.convertStringToDate(invForm.getDocDate()));
		wTax.setMyType(0);
		wTax.setIsExport(0);
		wTax.setCreatorCode(invForm.getCreatorCode());
		wTax.setCreateDateTime(new Date());
		
		return wTax;
	}

}
